// Copyright (c) 2010 Manuel Peinado Gallego <manuel.peinado@gmail.com>
// Distributed under the MIT license


#include "stdafx.h"
#include "WorldBuilder.h"
#include "Ray.h"


Ray::Ray(const gx::Vec3 & o, const gx::Vec3 & d)
: origin(o), direction(d)
{
    ASSERT(d.is_unit_length(1e-4));
}


Ray applyTransform(const Ray & ray, const gx::Mat4 & m)
{
    gx::Vec3 dir = m * Dir(ray.direction);
    return Ray(
        m * Pnt(ray.origin), 
        dir.normalize());
}
